--视杀如常
local shisharuchang = fk.CreateSkill {
    name = "mcdh_shisharuchang"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

shisharuchang:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        local logic = room.logic
        local  events =logic:getEventsOfScope(GameEvent.MoveCards,999,function(e)
            for _, move in ipairs(e.data) do
                if move.from == player.id then
                    local n = 0
                    for _, info in ipairs(move.moveInfo) do
                        if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
                            n = n + 1
                        end
                    end
                    return n >= 2
                end
            end
        end,Player.HistoryTurn)
        self.cost_data = #events
        return  player:hasSkill(self) and #events > 0 and target.phase == Player.Finish
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local num = self.cost_data
        for i = 1, num, 1 do
            if player.dead or #U.getDefaultTargets(player,Fk:cloneCard("slash"),true,false) == 0 then break end
            U.askForUseVirtualCard(room, player, "slash", nil, self.name, "#shisharuchang-use:::"..i..":"..num, false, true, false, true)
        end
    end,
})

shisharuchang:addEffect(fk.TargetSpecified,{
    can_refresh = function(self, event, target, player, data)
        return target == player and data.card and table.contains(data.card.skillNames, self.name)
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
            data.to:addQinggangTag(data)
    end,
})


Fk:loadTranslationTable {
    ["mcdh_shisharuchang"] = "视杀如常",
    [":mcdh_shisharuchang"] = "每名角色结束阶段，你可以视为使用X张无视防具的【杀】。（X为你本回合一次性失去至少两张牌的次数）",
    ["#shisharuchang-use"] = "视杀如常:视为使用【杀】。（第%arg张，共%arg2张）"
}

return shisharuchang